import { Big } from "../core/Big";
import { Point, Terrain } from "../core/Point";
import Utils from "../GameUtils";

export class 狙炮 extends Big{
    
    point_aim:Point = null

    turnStart() {
        if (this.point_aim != null) {
            this.shellLanding(this.point_aim)
            this.point_aim = null
        }
        this.actionTime = 1
        this.update()
    }

    terrainAdapt() {
        switch (this.point.terrain) {
            case Terrain.SHAN:
            case Terrain.SHUI:
                this.die(this.player)
        }
    }

    /** 炮弹落地 */
    shellLanding(endPoint:Point) {
        this.gameMgr.sendBroadcast(Utils.getObj("大炮_bombing",{"start":this.point.id,"end":endPoint.id}))
        setTimeout(()=>{
            let big_end = endPoint.big
            if(big_end != null) {
                big_end.attacked(this.player)
            }
        },600)
    }

}